package com.hhf.rpa.InputDeviceMonitor.impl2;

import java.awt.*;
import java.io.IOException;
import java.util.Date;

/**
 * 实现监控鼠标，超时打开远程文件再关闭，永久亮屏(其实这个功能没有用到Robot)
 */
public class MouseController implements Runnable {
    Robot rb;

    public MouseController(Robot robot) {
        rb = robot;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(10000);
                if (System.currentTimeMillis() - MouseMonitor.last.getTime() >= 10000) {
                    MouseMonitor.open("remote.rdp");
                    Thread.sleep(300);
                    MouseMonitor.close();
                    MouseMonitor.last = new Date();
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
//            rb.mouseMove(3500, 500);
//            rb.mouseMove(3500, 300);
//            rb.mousePress(InputEvent.BUTTON1_MASK);
//            rb.keyPress(KeyEvent.VK_0);
//            rb.keyPress(KeyEvent.VK_1);
        }
    }
}
